<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body layadmin-themealias="default">

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15="">

                    <div class="layui-form" wid100="" lay-filter="">
                        <!--
                        <div class="layui-form-item">
                            <label class="layui-form-label">类型</label>
                            <div class="layui-input-block">
                                <input type="radio" value="0" name="category" title="未配置" lay-verify="required" {$activity_info.category===0?'checked':''} lay-filter="category"  />
                                <input type="radio" value="1" name="category" title="注册送" lay-verify="required" {$activity_info.category===1?'checked':''} lay-filter="category"  />
                                <input type="radio" value="2" name="category" title="续费送" lay-verify="required" {$activity_info.category===2?'checked':''} lay-filter="category"  />
                            </div>
                        </div>-->

                        <div class="layui-form-item">
                            <input type="hidden" name="id" value="{$activity_info.id}">
                            <label class="layui-form-label">标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" value="{$activity_info.title}" class="layui-input" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">副标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="desc" value="{$activity_info.desc}" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">权重</label>
                            <div class="layui-input-inline">
                                <input type="text" name="weight" value="{$activity_info.weight}" class="layui-input" lay-verify="required">
                            </div>
                        </div>

                        <div class="layui-form-item" style="margin-bottom:0px">
                            <label class="layui-form-label">APP封面</label>
                            <div class="layui-input-inline" style="width: 60%;">
                                <input name="pic_cover_app" placeholder="图片地址" value="{$activity_info.pic_cover_app}" class="layui-input" id="pic_cover_app" lay-verify="required">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary LAY_iconImgUpload" lay-data="{idObjName: 'pic_cover_app'}">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="coverImgPreview" data-idname="pic_cover_app">查看图片</button>
                            </div>
                        </div>

                        <div class="layui-row">
                            <div  style="color: #f0ad4e;height:20px;line-height: 20px;margin-left:130px;font-size: 12px;margin-bottom: 2px">尺寸：351x134像素，格式：PNG,JEPG</div>
                        </div>

                        <div class="layui-form-item" style="margin-bottom:0px">
                            <label class="layui-form-label">APP详情页</label>
                            <div class="layui-input-inline" style="width: 60%;">
                                <input name="pic_detail_app" placeholder="图片地址" value="{$activity_info.pic_detail_app}" class="layui-input" id="pic_detail_app" lay-verify="required">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary LAY_iconImgUpload" lay-data="{idObjName: 'pic_detail_app'}">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="coverImgPreview" data-idname="pic_detail_app">查看图片</button>
                            </div>
                        </div>

                        <div class="layui-row">
                            <div  style="color: #f0ad4e;height:20px;line-height: 20px;margin-left:130px;font-size: 12px;margin-bottom: 2px">尺寸：375x165像素，格式：PNG,JEPG</div>
                        </div>

                        <div class="layui-form-item" style="margin-bottom: 0px">
                            <label class="layui-form-label">PC封面</label>
                            <div class="layui-input-inline" style="width: 60%;">
                                <input name="thumb_act" id="LAY_iconImgSrcOne" placeholder="图片地址" value="{$activity_info.thumb_act}" class="layui-input" lay-verify="required">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary  LAY_iconImgUpload" lay-data="{idObjName: 'LAY_iconImgSrcOne'}">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="coverImgPreview" data-idname="LAY_iconImgSrcOne">查看图片
                                </button>
                            </div>
                        </div>

                        <div class="layui-row">
                            <div  style="color: #f0ad4e;height:20px;line-height: 20px;margin-left:130px;font-size: 12px;margin-bottom: 2px">尺寸：1055x187像素，格式：PNG,JEPG</div>
                        </div>

                        <div class="layui-form-item" style="margin-bottom: 0px">
                            <label class="layui-form-label">PC详情页</label>
                            <div class="layui-input-inline" style="width: 60%;">
                                <input name="thumb_detail" id="LAY_iconImgSrcThree" placeholder="图片地址" value="{$activity_info.thumb_detail}" class="layui-input" lay-verify="required">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary  LAY_iconImgUpload" lay-data="{idObjName: 'LAY_iconImgSrcThree'}">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="coverImgPreview" data-idname="LAY_iconImgSrcThree">查看图片
                                </button>
                            </div>
                        </div>

                        <div class="layui-row">
                            <div  style="color: #f0ad4e;height:20px;line-height: 20px;margin-left:130px;font-size: 12px;margin-bottom: 2px">尺寸：1920x340像素，格式：PNG,JEPG</div>
                        </div>

                        <div class="layui-form-item" style="margin-bottom: 0px">
                            <label class="layui-form-label">PC底部封面</label>
                            <div class="layui-input-inline" style="width: 60%;">
                                <input name="thumb_url" id="thumb_url" placeholder="图片地址" value="{$activity_info.thumb_url}" class="layui-input" lay-verify="required">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary  LAY_iconImgUpload" lay-data="{idObjName: 'thumb_url'}">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="coverImgPreview" data-idname="thumb_url">查看图片
                                </button>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div  style="color: #f0ad4e;height:20px;line-height: 20px;margin-left:130px;font-size: 12px;margin-bottom: 2px">尺寸：264 x 110像素，格式：PNG,JEPG</div>
                        </div>

                        <div class="layui-form-item" id="start_div">
                            <label class="layui-form-label">开始时间</label>
                            <div class="layui-input-block">
                                <input type="text" name="start_time" placeholder="活动开始时间" autocomplete="off" class="layui-input" id="start_time_input" value="{$activity_info.start_time}" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item" id="end_div">
                            <label class="layui-form-label">结束时间</label>
                            <div class="layui-input-block">
                                <input type="text" name="end_time" placeholder="活动结束时间" autocomplete="off" class="layui-input" id="end_time_input" value="{$activity_info.end_time}">
                            </div>
                        </div>

                        <div class="layui-form-item" id="bind_bankcard">
                            <?php if ($activity_info['category'] >= 1){?>
                            <label class="layui-form-label">参与条件</label>
                            <div class="layui-input-block">
                                <input type="checkbox" value="1" name="bind_bankcard" title="是否绑定银行卡"  {$activity_info.bind_bankcard===1?'checked':''} />
                            </div>
                            <?php }?>
                        </div>

                        <div class="layui-form-item" id="zensongneirong">
                            <?php if ($activity_info['category'] >= 1){?>
                            <label class="layui-form-label">赠送内容</label>
                            <div class="layui-input-block">
                                <div style="padding: 5px 0px">
                                    &nbsp;宝 石 &nbsp;&nbsp;<input type="text" name="carat" value="{$activity_info.carat}" placeholder="宝石" autocomplete="off" style="padding-left: 5px;width: 100px;height: 22px" onkeyup="input_num(this)" lay-verify="required" />
                                </div>
                                <div style="padding: 5px 0px">
                                    &nbsp;钻 石 &nbsp;&nbsp;<input type="text" name="eagle_drill" value="{$activity_info.eagle_drill}" placeholder="钻石" autocomplete="off" style="padding-left: 5px;width: 100px;height: 22px" onkeyup="input_num(this)" lay-verify="required"/>
                                </div>
                                <div style="padding: 5px 0px">
                                    经验值 &nbsp;<input type="text" name="experience" value="{$activity_info.experience}" placeholder="经验值" autocomplete="off" style="padding-left: 5px;width: 100px;height: 22px" onkeyup="input_num(this)" lay-verify="required" />
                                </div>
                            </div>
                            <?php }?>
                        </div>

                        <!---

                        <div class="layui-form-item">
                            <label class="layui-form-label">开启奖励</label>
                            <div class="layui-input-block">
                                <input type="radio" name="open_reward" value="0" title="是" {$activity_info.open_reward===0?'checked':''}/>
                                <input type="radio" name="open_reward" value="1" title="否" {$activity_info.open_reward===1?'checked':''}/>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">活动礼物</label>
                            <div class="layui-input-inline">
                                <select name="gift_id" class="layui-select">
                                    <option value="">请先选择活动礼物</option>
                                    {volist name="gift_list" id="vo"}
                                    <option value="{$vo.id}" {$vo.id==$activity_info.gift_id?'selected':''}>{$vo.title}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">礼物数量</label>
                            <div class="layui-input-inline">
                                <input type="text" name="gift_num" value="{$activity_info.gift_num}" placeholder="礼物数量" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">奖励挂件</label>
                            <div class="layui-input-inline" id="propsArea" style="width:auto">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <button id="addProps" type="button" class="layui-btn layui-btn-warm layui-btn-sm">
                                            <i class="layui-icon">&#xe654;</i>添加挂件
                                        </button>
                                    </div>
                                </div>

                                {foreach $props_reward as $props_k=>$props_vo }
                                <div class="layui-form-item">
                                    <div class="layui-input-inline">
                                        <select name="props[{$props_k}][id]" class="layui-select" lay-verify="">
                                            <option value="">请先选择</option>
                                            {volist name="props_list" id="vo"}
                                            <option value="{$vo.id}" {$props_vo.id==$vo.id?'selected':''}>{$vo.name}</option>
                                            {/volist}
                                        </select>
                                    </div>

                                    <div class="layui-inline">
                                        <label class="layui-form-label">奖励挂件时效：</label>
                                        <div class="layui-input-inline">
                                            <select name="props[{$props_k}][duration]" class="layui-select">
                                                <option value="">请选择</option>
                                                {volist name="props_duration_cate" id="vo"}
                                                <option value="{$key}" {$props_vo.duration==$key?'selected':''}>{$vo}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <button type="button" class="layui-btn layui-btn-danger  layui-btn-sm removeProps">
                                            <i class="layui-icon">&#xe67e;</i>
                                        </button>
                                    </div>
                                </div>
                                {/foreach}
                            </div>
                        </div>-->

                        <div class="layui-form-item">
                            <label class="layui-form-label">内容</label>
                            <div class="layui-input-block"  style="z-index: 1">
                                <textarea placeholder="" class="layui-textarea" name="content" id="content" style="min-height: 300px;padding: 0;border: none;">{$activity_info.content}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block text-center">
                                <button class="layui-btn" lay-submit="" lay-filter="activity-edit">确认保存</button>
                                <button class="layui-btn layui-btn-primary" id="close">取消</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script src="/assets/cos-js-sdk-v5/cos-js-sdk-v5.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/assets/ue/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/assets/ue/ueditor.all.min.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate', 'admin', 'activity'], function () {
        var $ = layui.$
            , form = layui.form
            , laydate = layui.laydate
            , admin = layui.admin;

        $(this).removeAttr("lay-key");
        //执行一个laydate实例
        laydate.render({
            elem: '#start_time_input',
            trigger: 'click',
            type: 'datetime',
            min: '<?php echo date("Y-m-d H:i:s");?>',
        });
        laydate.render({
            elem: '#end_time_input',
            trigger: 'click',
            type: 'datetime',
            min: '<?php echo date("Y-m-d H:i:s");?>',
        });

        form.on('radio(category)', function (data) {
            if (data.value == 0) {
                $("#bind_bankcard").html('');
                $("#zensongneirong").html('');
            } else {
                var html1 = $("#bind_bankcard").html();
                var html2 = $("#zensongneirong").html();
                if (html1.replace(/^\s+|\s+$/g,'') && html2.replace(/^\s+|\s+$/g,'')) {
                    return false;
                }
                var bind_bankcardHtml = '<label class="layui-form-label">参与条件</label><div class="layui-input-block">';
                bind_bankcardHtml += '<input type="checkbox" value="1" name="bind_bankcard" title="是否绑定银行卡"  {$activity_info.bind_bankcard===0?"checked":""} /></div>';
                $("#bind_bankcard").html(bind_bankcardHtml);
                $("#zensongneirong").html('<label class="layui-form-label">赠送内容</label>\n' +
                    '                            <div class="layui-input-block">\n' +
                    '                                <div style="padding: 5px 0px">\n' +
                    '                                    &nbsp;宝 石 &nbsp;&nbsp;<input type="text" name="carat" value="{$activity_info.carat}" placeholder="宝石" autocomplete="off" style="padding-left: 5px;width: 100px;height: 22px" onkeyup="input_num(this)" lay-verify="required" />\n' +
                    '                                </div>\n' +
                    '                                <div style="padding: 5px 0px">\n' +
                    '                                    &nbsp;钻 石 &nbsp;&nbsp;<input type="text" name="eagle_drill" value="{$activity_info.eagle_drill}" placeholder="钻石" autocomplete="off" style="padding-left: 5px;width: 100px;height: 22px" onkeyup="input_num(this)" lay-verify="required"/>\n' +
                    '                                </div>\n' +
                    '                                <div style="padding: 5px 0px">\n' +
                    '                                    经验值 &nbsp;<input type="text" name="experience" value="{$activity_info.experience}" placeholder="经验值" autocomplete="off" style="padding-left: 5px;width: 100px;height: 22px" onkeyup="input_num(this)" lay-verify="required"/>\n' +
                    '                                </div>\n' +
                    '                            </div>');

            }
            form.render();
        });

        var index = parent.layer.getFrameIndex(window.name);

        $('#close').on("click", function () {
            parent.layer.close(index);
        });

        form.on('select(type_sel)', function (data) {
            if (data.value == 1) {
                $("#start_div").show();
                $("#end_div").show();
            } else {
                $("#start_div").hide();
                $("#end_div").hide();
            }
        });


        //动态添加挂件选择
        var props_total = 1;
        $("#addProps").click(function () {
            var str = `<div class="layui-form-item">
                                    <div class="layui-input-inline">
                                        <select name="props[${props_total}][id]" class="layui-select" lay-verify="required">
                                            <option value="">请先选择礼物</option>
                                            {volist name="props_list" id="vo"}
                                            <option value="{$vo.id}">{$vo.name}</option>
                                            {/volist}
                                        </select>
                                    </div>

                                    <div class="layui-inline">
                                        <label class="layui-form-label">奖励挂件时效：</label>
                                        <div class="layui-input-inline">
                                            <select name="props[${props_total}][duration]" class="layui-select">
                                                <option value="">请选择</option>
                                                {volist name="props_duration_cate" id="vo"}
                                                <option value="{$key}">{$vo}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <button type="button" class="layui-btn layui-btn-danger  layui-btn-sm removeProps">
                                            <i class="layui-icon">&#xe67e;</i>
                                        </button>
                                    </div>
                                </div>`


            $("#propsArea").append(str);
            layui.form.render("select");//重新渲染 固定写法
            props_total++;
        });

        //删除动态添加的挂件选择
        $("body").on('click', ".removeProps", function () {
            //元素移除前校验是否被引用
            var approvalName = $(this).parent().prev('div.layui-input-inline').children().val();
            var parentEle = $(this).parent().parent();
            parentEle.remove();
        });



        var ue = UE.getEditor('content');
        form.on('submit(activity-edit)', function (obj) {
            var data = obj.field;
            data.content = ue.getContent();
            //提交
            admin.req({
                url: '/admin/activity/edit_post'
                , type: 'post'
                , data: obj.field
                , success: function (res) {
                    if (res.code == 0) {
                        parent.layer.close(index);
                        parent.layer.msg(res.msg, {icon: 1});
                        parent.layui.table.reload('LAY-activity-manage');
                    }
                }
            });
            return false;
        });
    });

    function input_num(obj){
        obj.value = obj.value.replace(/[^\d.]/g,"");
        obj.value = obj.value.replace(/^\./g,"");
        obj.value = obj.value.replace(/\.{2,}/g,".");
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');

        if(obj.value.indexOf(".")> 0  && obj.value.indexOf("0")>2){
            obj.value= parseFloat(obj.value);
        }
        if(obj.value.indexOf(".")> 0  && obj.value.lastIndexOf("0")>2){
            obj.value= parseFloat(obj.value);
        }
        if (obj.value.indexOf(".") <= 0 && obj.value != "") {
            obj.value = parseFloat(obj.value);
        }
    }
</script>
</body>
</html>
